package com.cskaoyan.user.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.redisson.Redisson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
@Data
@AllArgsConstructor
@NoArgsConstructor
public class NoBlockSendMail implements Runnable {
    JavaMailSender mailSender;
    String email;
    String uid;

    @Override
    public void run() {
        sendMail(email,uid);
    }

    /**
     * 发送邮件
     * 异步发送
     * @param email 电子邮件
     * @param uid   uid
     */
    public void sendMail(String email,String uid){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("kerbaluiz@163.com");
        message.setTo(email);
        message.setSubject("csmall商城激活2");
        message.setText("http://localhost:8080/user/verify?uuid="+uid);
        mailSender.send(message);
    }
}
